//
var checkPhone = function(a) {
	var patrn = /^((?:13|15|18|14|17)\d{9}|0(?:10|2\d|[3-9]\d{2})[1-9]\d{6,7})$/;
	if(!patrn.exec(a)) return false;
	return true;
};

/*提示信息*/
function myalert(tip) {
	$('.tipcont').css('display', 'block');
	setTimeout(function() {
		$('.tipcont').css('display', 'none');
	}, 2000);
	$('.tipcont').text(tip);

};
/*遮罩显示*/
function tipshow() {
	$('.zhezhao').css('display', 'block');

};

$('.submit').click(function() {
	//下一步之前的所有验证

	var loanMoney = $('#loanMoney').val();
	var loanName = $('#loanName').val();
	var inputGroupSelect01 = $('#inputGroupSelect01').find("option:selected").text();
	var loanTelphone = $('#loanTelphone').val();
	var loanShortYan = $('#loanShortYan').val();
	if(loanMoney != '') {
		if(loanName != '' && loanName.length<5) {
			if(inputGroupSelect01 == '男' || inputGroupSelect01 == '女') {
				if(checkPhone(loanTelphone)) {
					//腾讯
					
					
					/*$.ajax({
								type: "post",
								url: "",
								async: true,
								success: function(data) {
									console.log(data);
									//判断短信验证码正确
									countdown =  setInterval(down,1000);
								}

							});*/

				} else {
					myalert('请输入正确的手机号！！！');
				}
			} else {
				myalert('请选择性别！！！');
			}

		} else {
			myalert('请输入正确的姓名！！！');
		}
	} else {
		myalert('请输入您需要的金额！！！');
	}
});

window.callback = function(res){
    console.log(res);
    // res（用户主动关闭验证码）= {ret: 2, ticket: null}
    // res（验证成功） = {ret: 0, ticket: "String", randstr: "String"}
    if(res.ret === 0){
        alert(res.ticket)  ; // 票据
    }
};

var count =59;
var countdown;
//时间递减
function down(){
	$('.huo').html("" + count + "s");
	if (count == 0) {
		$(".huo").text("重新获取").removeAttr("disabled");
		clearInterval(countdown);
	}
	count--;
};

